<?php

require 'Response.php';
require 'DB.php';

$phone=empty($_REQUEST['phone'])?'':$_REQUEST['phone'];
$password=empty($_REQUEST['password'])?'':$_REQUEST['password'];
//$create_time=date('Y-m-d H:i:s',time()+7*3600);


//3、增加
$pdo=DB::getInstance()->connect();
$stmt=$pdo->query("SELECT * FROM `user` WHERE phone='$phone'");
$user=$stmt->fetch();
if (empty($user)){
    Response::json('-1','账号不存在！');
}
if ($user['password']==$password){
    Response::json('200','登录成功！',$user);
    session_start();
    $_SESSION['phone']=$phone;
}else{
    Response::json('-1','密码不正确！');
}


//$stmt = $pdo->query("SELECT * FROM `news`" . $str_search);
////$stmt = $pdo->query(); //返回一个PDOStatement对象
//$data = $stmt->fetchAll();//获得所有

//Response::json('200','成功',$data);
